<%@page import="java.util.HashMap"%>
<%@page import="java.util.Map"%>
<%@page import="com.situ.web.entity.Student"%>
<%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<%
		request.setAttribute("age", 18);
		request.setAttribute("gender", "男");
	%>
	<!-- 通过jstl向域对象中存放数据 -->
	<c:set var="name" value="zhangsan"></c:set>
	${name}
	<hr/>
	<!-- 1、单条件判断 -->
	<c:if test="${age==18}">
		今年18岁了
	</c:if>
	
	<c:if test="${gender=='男'}">
		男
	</c:if>
	<c:if test="${gender=='女'}">
		女
	</c:if>
	<br/>
	
	<!-- 2、多条件判断 if--else if---else if---else -->
	<%-- 
		<c:choose>
			<c:when test=""></c:when>
			<c:when test=""></c:when>
			<c:when test=""></c:when>
			<c:otherwise></c:otherwise>
		</c:choose> 
	--%>
	<c:set var="score" value="90"></c:set>
	<c:choose>
		<c:when test="${score>=90 && score<=100}">
			优秀
		</c:when>
		<c:when test="${score>=80 && score<90}">
			良好
		</c:when>
		<c:when test="${score>=70 && score<80}">
			一般
		</c:when>
		<c:when test="${score>=60 && score<70}">
			及格
		</c:when>
		<c:otherwise>
			不及格
		</c:otherwise>
	</c:choose>
	
	
	<hr/>
	<!-- 3、集合的遍历 
		3.1 List<String>
		3.2 List<Student>
		3.3 Map<String,String>   Map<String,Student>
	-->
	<c:forEach begin="0" end="5" var="i">
		${i}<br/>
	</c:forEach>
	<!-- step=2  原来这个循环i++ 改为i=i+2  -->
	<c:forEach begin="0" end="5" var="i" step="2">
		${i}<br/>
	</c:forEach>
	
	<!-- 3.1 List<String> -->
	<%
		List<String> strList = new ArrayList<String>();
	    strList.add("张三1");
	    strList.add("张三2");
	    strList.add("张三3");
	    request.setAttribute("strList", strList);
	%>
	<c:forEach items="${strList}" var="str">
		${str}<br/>
	</c:forEach>
	
	<!-- 3.2 List<Student> -->
	<%
		List<Student> list = new ArrayList<Student>();
		Student student1 = new Student(1, "张三11", 23, "男");
		Student student2 = new Student(2, "张三22", 23, "男");
		list.add(student1);
		list.add(student2);
		application.setAttribute("list", list);
	%>
	<c:forEach items="${list}" var="student">
		${student.name}--${student.age}<br/>
	</c:forEach>
	
	<!-- 3.3 Map<String,String>   Map<String,Student> -->
	<%
		Map<String,String> map = new HashMap<String,String>();
		map.put("cn", "中国");
		map.put("us", "美国");
		request.setAttribute("map", map);
	%>
	<c:forEach items="${map}" var="entry">
		${entry.key}--${entry.value}<br/>
	</c:forEach>
	<%
		Student stu1 = new Student(1, "李四11", 23, "男");
		Student stu2 = new Student(2, "李四22", 23, "男");
		Map<String,Student> map2 = new HashMap<String,Student>();
		map2.put("stu1", stu1);
		map2.put("stu2", stu2);
		request.setAttribute("map2", map2);
	%>
	<c:forEach items="${map2}" var="entry">
		${entry.key}--${entry.value}--${entry.value.name}<br/>
	</c:forEach>
	
	
	
</body>
</html>